﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Runtime.Serialization;
using System.Web;
using System.Web.Mvc;

namespace LynxWebLog
{
    [DataContract(Namespace = "http://schemas.datacontract.org/2004/07/LynxBlogAPI.Models")]
    public class PageData
    {
        [DataMember]
        public int pageid { get; set; }
        [DataMember]
        public string blogid { get; set; }
        [DataMember]
        public string title { get; set; }
        [DataMember, AllowHtmlAttribute]
        public string description { get; set; }
        [DataMember]
        public string wp_page_parent_id { get; set; }
        [DataMember]
        public string wp_page_order { get; set; }
        [DataMember]
        public bool IsPublished { get; set; }
        [DataMember, DataType(DataType.Date), DisplayFormat(DataFormatString="{0:yyyy-MM-dd}", ApplyFormatInEditMode=true)]
        public DateTime DateCreated { get; set; }
        [DataMember]
        public string license { get; set; }
        [DataMember]
        public bool CommentsClosed { get; set; }

        public PageData() { }

        public PageData(Page page, string blogid, DateTime dt, string license = "", bool commentsclosed = true)
        {
            this.pageid = page.pageid;
            this.blogid = blogid;
            this.title = page.title;
            this.description = page.description;
            this.wp_page_parent_id = page.wp_page_parent_id;
            this.wp_page_order = page.wp_page_order;
            this.IsPublished = page.IsPublished;
            if (dt == DateTime.MinValue) dt = DateTime.Now;
            this.DateCreated = dt;
            this.license = license;
            this.CommentsClosed = commentsclosed;
        }

    }
}